﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Speech.Synthesis;
using System.Text;
using System.Threading.Tasks;

namespace 语音播报Demo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            PlayAsync("你好");
        }

        public static void PlayAsync(string word)
        {
            //reader.SpeakCompleted += Reader_SpeakCompleted;
                using (SpeechSynthesizer reader = new SpeechSynthesizer())
                {
                    reader.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.Teen);
                    //reader.SelectVoice("Microsoft Huihui Desktop");
                    Prompt p = reader.SpeakAsync(word);
                    while (true)
                    {
                        if (p.IsCompleted)
                        {
                            break;
                        }
                    }
                }
        }

    }
}
